package com.yypx.action;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.yypx.entity.Student;
import com.yypx.entity.StudentType;
import com.yypx.entity.TypeValueObject;
import com.yypx.service.CertificateTypeService;
import com.yypx.service.StudentService;
import com.yypx.service.StudentTypeService;

@Scope("prototype")
@Component("testAction")
public class TestAction extends BaseAction {
	@Autowired
	private StudentService studentService;
	@Autowired
	private CertificateTypeService certificateTypeService;
	@Autowired
	private StudentTypeService studentTypeService;
	private List<StudentType> statusList;
	private List<TypeValueObject> ttList;
	private List<Map<String, Object>> resultList;

	public String addSave() throws Exception {
		Student student = new Student();
		student.setSid(UUID.randomUUID());
		student.setSname(getRequest().getParameter("uname"));
		studentService.add(student);
		return "list";
	}

	public String list() throws Exception {
		List<Student> list = studentService.selAll();
		resultList = studentService.getResultList(list);
		ttList = certificateTypeService.listAll();
		statusList = studentTypeService.selAll();
		return "list";
	}

	public void setResultList(List<Map<String, Object>> resultList) {
		this.resultList = resultList;
	}

	public List<Map<String, Object>> getResultList() {
		return resultList;
	}

	public void setStatusList(List<StudentType> statusList) {
		this.statusList = statusList;
	}

	public List<StudentType> getStatusList() {
		return statusList;
	}

	public void setTtList(List<TypeValueObject> ttList) {
		this.ttList = ttList;
	}

	public List<TypeValueObject> getTtList() {
		return ttList;
	}
}
